#ifndef __HEAD__
#define __HEAD__
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <ctype.h>
#include <stdint.h>
#include <time.h>
#include <math.h>
#include <unistd.h>
#include <pthread.h>
#include <fcntl.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <errno.h>
#include <stdbool.h>
#include <dirent.h>
#include <pwd.h>
#include <grp.h>
#include <sys/mman.h>
#include <sys/select.h>
#include <sys/time.h>
#include <sys/wait.h>
#include <signal.h>
#include <pthread.h>
#include <netdb.h>
#include <sys/socket.h>
#include <arpa/inet.h>
#include <netinet/in.h>
#include <sys/epoll.h>
#include <sys/sendfile.h>
#include <crypt.h>
#define ARGS_CHECK(argc,expected)\
	do{\
		if((argc)!=(expected)){\
			fprintf(stderr,"args num error!\n");\
			exit(-1);\
		}\
	}while(0)
//检查返回值是否错误匹配，若是则打印msg和错误信息
#define ERROR_CHECK(ret,error_flag,msg)\
	do{\
		if((ret)==(error_flag)){\
			perror(msg);\
			exit(-2);\
		}\
	}while(0)
#define THREAD_ERROR_CHECK(ret,msg) {\
	if(ret!=0){\
		fprintf(stderr,"%s:%s\n",msg,strerror(ret));\
	}\
}


enum TYPE{
    DATA,
    CD,
    LS,
    PUTS,
    GETS,
    REMOVE,
    PWD,
    MKDIR
};

typedef struct train_s{
    int type;
    int len;
    char data[1000];
}train_t;

//建立TCP链接
int tcp_Init(char *ip,char *port);

/* int upload(int sockfd,char *filename); */
/* int download(int sockfd,char * filename); */

int send_cmd(char *line,int sockfd);
int check_cmd(char *line);
int c_recv_download(int sockfd,char *filename);
int c_up(int sockfd,char *filename);
int sendLogin(int sockfd);
#endif

